﻿using Domain.Factory_Modeling;
using Domain.Process_Procedures;
using Domain.Production_Modules;
using Infratructure.Interface;
using MediatR;
using MES.Server.API.Application.Command.Production_Modules.Pulldown;
using ReturnValue;
using System.Diagnostics;

namespace MES.Server.API.Application.Handler.Production_Modules.Pulldown
{
    public class ProcessFlowQueryCommandHandler : IRequestHandler<ProcessFlowQueryCommand, ApiResult<List<ProcessFlowModel>>>
    {
        private readonly IRepository<ProcessFlowModel> ProductionLineRepo;
        public ProcessFlowQueryCommandHandler(IRepository<ProcessFlowModel> ProductionLineRepo)
        {
            this.ProductionLineRepo = ProductionLineRepo;
        }
        public Task<ApiResult<List<ProcessFlowModel>>> Handle(ProcessFlowQueryCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<ProcessFlowModel>> result = new ApiResult<List<ProcessFlowModel>>();
            result.Code = StatusCode.Success;
            result.Message = StatusCode.Success.ToString();
            var list = ProductionLineRepo.GetAll();
            result.Data = list.ToList();
            return Task.FromResult(result);
        }
    }
}
